Skip to content

Prometheus: Add PrometheusQueryRangeResponseListener (ES|QL → Prometheus matrix JSON) + unit tests#144302

Merged
felixbarny merged 4 commits intoelastic:mainfrom
felixbarny:promql-query-range-pr2
Mar 19, 2026
Merged

Prometheus: Add PrometheusQueryRangeResponseListener (ES|QL → Prometheus matrix JSON) + unit tests#144302
felixbarny merged 4 commits intoelastic:mainfrom
felixbarny:promql-query-range-pr2

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 16, 2026

Summary

This is PR 2 of 4 in a stacked series that adds the Prometheus query_range endpoint.
See the overview PR #144294 for context.
Stacks on top of #144301 — please review that PR first.

Adds the ES|QL → Prometheus matrix JSON conversion layer, independently reviewable without needing to know the REST wiring.

PrometheusQueryRangeResponseListener

Listens for an EsqlQueryResponse and converts its columnar PROMQL output into the Prometheus range query JSON format.

PrometheusQueryRangeResponseListenerTests

Unit tests covering conversion paths, edge cases, error JSON mapping, and special float formatting.

Stacking order

@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Mar 16, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

Adds the ES|QL → Prometheus matrix JSON conversion layer:

- `PrometheusQueryRangeResponseListener` converts an `EsqlQueryResponse`
  (columnar PROMQL output) into the Prometheus range query JSON format.
  Handles two column modes:
    * `_timeseries` JSON column — unwraps the `labels` namespace and
      dot-flattens other namespaces.
    * Individual label columns — maps each column name to a metric label.
  Also converts epoch-ms timestamps to epoch-second doubles and formats
  NaN / ±Inf sample values as Prometheus expects.
- `PrometheusQueryRangeResponseListenerTests` covers every conversion path,
  edge cases (empty result, missing columns), error JSON building, and
  special float formatting.
felixbarny and others added 2 commits March 19, 2026 07:42
…/prometheus/rest/PrometheusQueryRangeResponseListenerTests.java

Co-authored-by: Sergey Sidorov <SERGEY.IVANOVICH.SIDOROV@gmail.com>
@felixbarny felixbarny marked this pull request as ready for review March 19, 2026 06:42
Copy link
Copy Markdown
Contributor

@kkrik-es kkrik-es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply comments from the parent, as applicable.

@felixbarny felixbarny enabled auto-merge (squash) March 19, 2026 11:01
@felixbarny felixbarny merged commit 20d9166 into elastic:main Mar 19, 2026
40 checks passed
ncordon pushed a commit to ncordon/elasticsearch that referenced this pull request Mar 20, 2026
michalborek pushed a commit to michalborek/elasticsearch that referenced this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :StorageEngine/PromQL PromQL support for Elastic Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants